<!DOCTYPE html>
<!--<html xmlns:th="http://www.thymeleaf.org" lang="en">-->
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <title th:text="${fileEntity.title}"></title>
    <!--适配屏幕大小的-->
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <link rel="stylesheet" href="../static/css/bootstrap.min.css"/>
    <script src="../static/js/jquery-3.3.1.min.js" ></script>
    <script src="../static/js/popper.min.js"></script>
    <script src="../static/js/bootstrap.min.js"></script>
    <!--kindeditor-->
    <link rel="stylesheet" href="../static/themes/default/default.css" />
    <script charset="utf-8" src="../static/js/kindeditor-min.js"></script>
    <script charset="utf-8" src="../static/js/zh_CN.js"></script>
    <style>
        #menu{
            position: fixed;
            top: 10px;
        }
        #div1{
            position: absolute;
            top: 10px;
            left: 130px;
        }
    </style>
</head>
<body background="../static/img/3.jpg" style="background-attachment: fixed;background-size: 100%,100%">
    <div class="container" id="menu" >
        <button class="btn btn-primary" id="back">返回</button>
    </div>
    <div class="container" id="div1">
        <div class="card">
            <div id="card-header" class="card-header bg-warning" style="color: #007bff">
                <label for="comment" th:text="${fileEntity.title}"></label>
            </div>
            <div id="card-body" class="card-body bg-secondary text-white">
                <form id="form1" action="/update" method="post">
                    <textarea id="comment" name="content" style="width:1070px;height:400px;visibility:hidden;" th:utext="${fileEntity.content}"></textarea>
                    <p>
                        <br>
                            <input type="hidden" name="id" id="input1" th:value="${fileEntity.id}" />
                            <input type="button" name="getHtml" class="btn btn-success" value="保存文档" />
                        </br>
                    </p>
                </form>
            </div>
        </div>
    </div>

    <div class="container">
        <button type="button" hidden="hidden" id="chufa" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
            打开模态框
        </button>
        <!--模态框-->
        <div class="modal fade" id="myModal">
            <div class="modal-dialog">
                <div class="modal-content">
                    <!--模态框头部-->
                    <div class="modal-header">
                        <h4 class="modal-tittle">返回信息</h4>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                    </div>
                    <!--模态框主体-->
                    <div id="modal-body" class="modal-body">

                    </div>
                    <!--模态框底部-->
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        var editor;
        KindEditor.ready(function(K) {
            editor = K.create('textarea[name="content"]', {
                allowFileManager : true,
                items: [

                ]
            });
            K('input[name=getHtml]').click(function(e) {
                 // alert(editor.html());
                var params = {};
                params.id = $("#input1").val();
                params.content = editor.html();
                $.ajax({
                    type: "post",
                    url: "/update",
                    dataType: "json",
                    data: params,
                    async: false,
                    success: function(data){
                        $("#modal-body").html(data.msg);
                        $("#chufa").trigger('click');
                        // alert(data.ret_code);
                    }
                });


            });
            // K('input[name=isEmpty]').click(function(e) {
            //     alert(editor.isEmpty());
            // });
            // K('input[name=getText]').click(function(e) {
            //     alert(editor.text());
            // });
            // K('input[name=selectedHtml]').click(function(e) {
            //     alert(editor.selectedHtml());
            // });
            // K('input[name=setHtml]').click(function(e) {
            //     editor.html('<h3>Hello KindEditor</h3>');
            // });
            // K('input[name=setText]').click(function(e) {
            //     editor.text('<h3>Hello KindEditor</h3>');
            // });
            // K('input[name=insertHtml]').click(function(e) {
            //     editor.insertHtml('<strong>插入HTML</strong>');
            // });
            // K('input[name=appendHtml]').click(function(e) {
            //     editor.appendHtml('<strong>添加HTML</strong>');
            // });
            // K('input[name=clear]').click(function(e) {
            //     editor.html('');
            // });
        });

        $("#back").click(function(){
            window.location.href = "/";
        });

        $("#commit").click(function(){
           $("#form1").submit();        //提交表单
        });


    </script>

</body>
</html>
